{% extends "index.html" %}
{% block title %}
    电梯设备信息
{% endblock %}
{% block page_nav %}
	<li>电梯</li>
    <li>添加电梯</li>
{% endblock %}
{#页面内容#}
{% block content %}
    <!--数据录入-->
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-title">
                    <div style="margin-bottom: 30px; border-bottom: #2b333e; border-bottom-style: solid; padding-bottom: 15px">
                        <h3>电梯设备信息录入</h3>
                    </div>
                    {% if messages %}
                        <div class="alert alert-warning">
                            {% for message in messages %}
                                {% for key in messages[message] %}
                                    <p>{{ key }}</p>
                                {% endfor %}
                            {% endfor %}
                        </div>
                    {% endif %}
                </div>
                <div class="card-body">
                    <form id="form" class="form-horizontal" method="post" action="{{ url_for('view.elevator_machine_data_input') }}">
                        <div class="form-group">
                            <label class="control-label col-md-1" for="rSpeed">额定速度</label>
                            <div class="col-md-2">
                                <input id="rSpeed" class="form-control" type="text" name="rSpeed" placeholder="额定速度(m/s)" required>
                            </div>
                            <label class="control-label col-md-2" for="rLoad">额定载重量</label>
                            <div class="col-md-2">
                                <input id="rLoad" class="form-control" type="text" name="rLoad" placeholder="额定载重量(kg)" required>
                            </div>
                            <label class="control-label col-md-1" for="fN">层</label>
                            <div class="col-md-1">
                                <input id="fN" class="form-control" type="text" name="fN" placeholder="层" required>
                            </div>
                            <label class="sr-only" for="sN">站</label>
                            <div class="col-md-1">
                                <input id="sN" class="form-control" type="text" name="sN" placeholder="站" required>
                            </div>
                            <label class="sr-only" for="dN">门</label>
                            <div class="col-md-1">
                                <input id="dN" class="form-control" type="text" name="dN" placeholder="门" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="controlMode">控制方式</label>
                            <div class="col-md-2">
                                <select id="controlMode" name="controlMode" class="form-control">
                                    <option value="信号">信号</option>
                                    <option value="集选" selected="selected">集选</option>
                                    <option value="群控">群控</option>
                                    <option value="按钮">按钮</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="carDecorate">轿厢装修</label>
                            <div class="col-md-2">
                                <select id="carDecorate" name="carDecorate" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="icCard">IC卡</label>
                            <div class="col-md-2">
                                <select id="icCard" name="icCard" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="autoRescuer">自动救援</label>
                            <div class="col-md-2">
                                <select id="autoRescuer" name="autoRescuer" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="energyFeedback">能量反馈</label>
                            <div class="col-md-2">
                                <select id="energyFeedback" name="energyFeedback" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="internetOfThings">物联网</label>
                            <div class="col-md-2">
                                <select id="internetOfThings" name="internetOfThings" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                        </div>
                        <!--分隔符-->
                        <div class="card-diver">
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="machineType">主机型式</label>
                            <div class="col-md-2">
                                <select id="machineType" name="machineType" class="form-control">
                                    <option value="同步" selected="selected">同步主机</option>
                                    <option value="异步">异步主机</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="machineModel">主机型号</label>
                            <div class="col-md-2">
                                <input id="machineModel" class="form-control" type="text" name="machineModel" placeholder="主机型号" required>
                            </div>
                            <label class="control-label col-md-2" for="machineNumber">主机编号</label>
                            <div class="col-md-2">
                                <input id="machineNumber" class="form-control" type="text" name="machineNumber" placeholder="主机编号" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="manualOperate">手动紧急操作装置</label>
                            <div class="col-md-2">
                                <select id="manualOperate" name="manualOperate" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="ascendOverspeed">上行超速保护装置</label>
                            <div class="col-md-2">
                                <select id="ascendOverspeed" name="ascendOverspeed" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="ucmp">意外移动保护装置</label>
                            <div class="col-md-2">
                                <select id="ucmp" name="ucmp" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                        </div>
                        <!--分隔符-->
                        <div class="card-diver">
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="speedGovernMethod">调速方式</label>
                            <div class="col-md-2">
                                <select id="speedGovernMethod" name="speedGovernMethod" class="form-control">
                                    <option value="变频" selected="selected">变频</option>
                                    <option value="双速">双速</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="controlCabinetModel">控制柜型号</label>
                            <div class="col-md-2">
                                <input id="controlCabinetModel" class="form-control" type="text" name="controlCabinetModel" placeholder="主机型号" required>
                            </div>
                            <label class="control-label col-md-2" for="controlCabinetNumber">控制柜编号</label>
                            <div class="col-md-2">
                                <input id="controlCabinetNumber" class="form-control" type="text" name="controlCabinetNumber" placeholder="主机编号" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="emEOperate">紧急电动运行</label>
                            <div class="col-md-2">
                                <select id="emEOperate" name="emEOperate" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="doorBypass">旁路装置</label>
                            <div class="col-md-2">
                                <select id="doorBypass" name="doorBypass" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="doorLoopDetect">门回路检测</label>
                            <div class="col-md-2">
                                <select id="doorLoopDetect" name="doorLoopDetect" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="phaseFaultProtect">断错相保护</label>
                            <div class="col-md-2">
                                <select id="phaseFaultProtect" name="phaseFaultProtect" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="brakeFProtect">制动器故障保护</label>
                            <div class="col-md-2">
                                <select id="brakeFProtect" name="brakeFProtect" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="governorManufactureDate">限速器出厂日期</label>
                            <div class="col-md-2">
                                <input id="governorManufactureDate" class="form-control datepicker" type="text" name="governorManufactureDate" placeholder="限速器出厂日期" required>
                            </div>
                            <label class="control-label col-md-2" for="governorCheckDate">限速器校验日期</label>
                            <div class="col-md-2">
                                <input id="governorCheckDate" class="form-control datepicker" type="text" name="governorCheckDate" placeholder="校验日期" required>
                            </div>
                            <label class="sr-only" for="governorSpeed">校验速度</label>
                            <div class="col-md-2">
                                <input id="governorSpeed" class="form-control" type="text" name="governorSpeed" placeholder="校验速度(m/s)" required>
                            </div>
                        </div>
                        <!--分隔符-->
                        <div class="card-diver">
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="compensateChain">补偿链</label>
                            <div class="col-md-2">
                                <select id="compensateChain" name="compensateChain" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="compensateRopeSwitch">补偿链电气装置</label>
                            <div class="col-md-2">
                                <select id="compensateRopeSwitch" name="compensateRopeSwitch" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="compRebound">补偿链防跳装置</label>
                            <div class="col-md-2">
                                <select id="compRebound" name="compRebound" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="suspensionType">悬挂装置类型</label>
                            <div class="col-md-2">
                                <select id="suspensionType" name="suspensionType" class="form-control">
                                    <option value="钢丝绳" selected="selected">钢丝绳</option>
                                    <option value="钢带">钢带</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="ropeDiameter">钢丝绳(带)直径</label>
                            <div class="col-md-2">
                                <input id="ropeDiameter" class="form-control" type="text" name="ropeDiameter" placeholder="钢丝绳（带）直径" required>
                            </div>
                            <label class="control-label col-md-2" for="ropeNumber">钢丝绳(带)数量</label>
                            <div class="col-md-2">
                                <input id="ropeNumber" class="form-control" type="text" name="ropeNumber" placeholder="钢丝绳（带）数量" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="wellSafetyDoor">井道安全门</label>
                            <div class="col-md-2">
                                <select id="wellSafetyDoor" name="wellSafetyDoor" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="wellAccessDoor">井道检修门</label>
                            <div class="col-md-2">
                                <select id="wellAccessDoor" name="wellAccessDoor" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="safetyWindow">安全窗</label>
                            <div class="col-md-2">
                                <select id="safetyWindow" name="safetyWindow" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="carOverArea">轿厢超面积</label>
                            <div class="col-md-2">
                                <select id="carOverArea" name="carOverArea" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="overloadProtect">超载保护装置</label>
                            <div class="col-md-2">
                                <select id="overloadProtect" name="overloadProtect" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="cwSaftyGear">对重安全钳</label>
                            <div class="col-md-2">
                                <select id="cwSaftyGear" name="cwSaftyGear" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="carDoorLock">轿门门锁</label>
                            <div class="col-md-2">
                                <select id="carDoorLock" name="carDoorLock" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="carDoorRestrOp">轿门开门限制</label>
                            <div class="col-md-2">
                                <select id="carDoorRestrOp" name="carDoorRestrOp" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="glassDoor">玻璃门</label>
                            <div class="col-md-2">
                                <select id="glassDoor" name="glassDoor" class="form-control">
                                    <option value="有">有</option>
                                    <option value="无" selected="selected">无</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1" for="autoDoorClose">自动关门装置</label>
                            <div class="col-md-2">
                                <select id="autoDoorClose" name="autoDoorClose" class="form-control">
                                    <option value="有" selected="selected">有</option>
                                    <option value="无">无</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="bufferType">缓冲器型式</label>
                            <div class="col-md-2">
                                <select id="bufferType" name="bufferType" class="form-control">
                                    <option value="耗能型" selected="selected">耗能型</option>
                                    <option value="蓄能型">蓄能型</option>
                                </select>
                            </div>
                            <label class="control-label col-md-2" for="cwOvDis">对重缓冲距</label>
                            <div class="col-md-2">
                                <input id="cwOvDis" class="form-control" type="text" name="cwOvDis" placeholder="对重缓冲距(mm)" required>
                            </div>
                        </div>
                        <div class="card-footer">
                            <div class="row">
                                <div class="col-md-2 col-md-offset-4" >
                                    <button id="btn_submit" class="btn btn-primary icon-btn" type="button"><i class="fa fa-fw fa-lg fa-check-circle"></i>提交</button>
                                </div>
                                <div class="col-md-2">
                                    <button id="btn_reset" class="btn btn-primary icon-btn" type="reset"><i class="fa fa-fw fa-lg fa-refresh"></i>重置</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block script %}
    {{ super() }}
    {# 日期选择器插件bootstrap-datepicker #}
    <script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js') }}"></script>
    {# 电梯初始数据加载 #}
    <script type="text/javascript" src="{{ url_for('static', filename='js/elevator_data.js') }}"></script>
    {# 提示插件 #}
    <script type="text/javascript" src="{{ url_for('static', filename='js/alert.js') }}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var key;
            {% if elevator_cp_data != '' %}
                {#for (key in dics){#}
                {#    $('#'+key).val(dics[key]);#}
{#            {% else %}#}
                {% for key in elevator_cp_data %}
                    $('#{{ key }}').val("{{ elevator_cp_data[key] }}");
                {% endfor %}
            {% endif %}
        });

        <!--输入数据逻辑判断，出错则输出错误信息-->
        function warning(){
            var failtext = [];
            var velocity = parseFloat($('#rSpeed').val());
            var governorSpeed = parseFloat($('#governorSpeed').val());

            {#安装日期与制造日期比较#}
            if ($('#governorCheckDate').val() < $('#governorManufactureDate').val()) {
                failtext.push('限速器校验日期不可早于出厂日期');
            }

            {#验证限速器动作速度是否符合要求#}
            if (governorSpeed < velocity*1.15 || governorSpeed > velocity*1.25+0.25/velocity){
                failtext.push('限速器动作速度不符合要求');
            }

            return failtext;
        }
        $('#btn_submit').click(function () {
            var message = warning();
            if (message.length > 0){
                ShowTipAlwaysInTheMiddle(message[0], 'danger');
            }
            else {
                $('#form').submit()
            }

        });

        $('#btn_reset').click(function () {
            location.reload();
        });
    </script>
{% endblock %}